<%@ page 	contentType="text/html; charset=UTF-8" 
		 	import="org.apache.log4j.Logger"
			pageEncoding="UTF-8" 
%>
<%! 
	final static private Logger LOGGER = Logger.getLogger("org.javaongems.server.view.jsp.Layout");
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%
  if (LOGGER.isDebugEnabled()) LOGGER.debug("called layout.jsp");

  org.javaongems.server.EntryPointPage gemPage =(org.javaongems.server.EntryPointPage) request.getAttribute(org.javaongems.server.EntryPointPage.GEM_PAGE_OBJ);
  String appCtx = gemPage.getApplicationContext();
  java.util.Map gemProps = gemPage.getGemProperties();
  java.util.Map pageCargo = gemPage.getCargo();
  
  String gwtModule = (String) pageCargo.get("gwt:module");
  String title = (String) pageCargo.get("page.title");
  if (!org.javaongems.runtime.lang.StringUtils.isEmpty(title))
  	title = "No title specified";
  String applCss = (String) pageCargo.get("page.css");
  
  String north = (String) pageCargo.get("north");
  String south = (String) pageCargo.get("south"); 
  String east = (String) pageCargo.get("east");
  String west = (String) pageCargo.get("west");
  String footer = (String) pageCargo.get("footer");
  
  String banner = (String) pageCargo.get("banner");
  String breadcrumbLinks = (String) pageCargo.get("breadcrumbLinks");
  String mainContent = (String) pageCargo.get("mainContent");
  
  String gemPropsSection = gemPage.getGemPropertiesJsSection();
%>

<html>
	<head>
		<title><%= title %></title>
		<meta name='gwt:module' content='<%= gwtModule %>'>
		<link rel='stylesheet' href='<%=applCss%>'>
		<%= gemPropsSection %>
	</head>
	<body>
		<iframe id="__gwt_historyFrame" style="width:0;height:0;border:0"></iframe>
		<a name="top"></a>
		
		<div id="displayAreaPage">
			<div id="displayAreaTopStrip">
			</div>
		  	<div id="displayAreaBanner">
				<%
					if (!org.javaongems.runtime.lang.StringUtils.isEmpty(banner))
						out.print(banner);
				%>
		  	</div>
		  	<div id="displayAreaActionBar"></div>
			<div id="displayAreaBreadcrumbs">
				<%
					if (!org.javaongems.runtime.lang.StringUtils.isEmpty(breadcrumbLinks))
						out.print(breadcrumbLinks);
				%>
			</div>

			<div id="displayAreaContent">
				<div id="displayAreaContentNorth">
				<%
					if (!org.javaongems.runtime.lang.StringUtils.isEmpty(north))
						out.print(north);
				%>
				</div>
				<div id="displayAreaContentEast">
				<%
					if (!org.javaongems.runtime.lang.StringUtils.isEmpty(east))
						out.print(east);
				%>
				</div>
				<div id="displayAreaContentWest">
				<%
					if (!org.javaongems.runtime.lang.StringUtils.isEmpty(west))
						out.print(west);
				%>
				</div>
				<div id="displayAreaContentMain">
				<%
					if (!org.javaongems.runtime.lang.StringUtils.isEmpty(mainContent))
						out.print(mainContent);
				%>
			  	</div>
				<div id="displayAreaContentSouth">
				<%
					if (!org.javaongems.runtime.lang.StringUtils.isEmpty(south))
						out.print(south);
				%>
				</div>
			</div>
			
			<div id="displayAreaFooter">
				<%
					if (!org.javaongems.runtime.lang.StringUtils.isEmpty(footer))
						out.print(footer);
				%>
			</div>
			<hr/>
			<div id="jumpDebugArea" style="border: 1px solid #841;">
				<div id="gemDebugText" style="width:100%; height: 100px; overflow: auto;"></div>
				<button onclick="gemOutClear();"> clear </button>
			</div>
			
			
			<script>
			__gwt_historyResourceLocation = "<%=appCtx%>jsps/history.jsp";
			
			function gemOutPrintln(msg) {
			  var out = document.getElementById("gemDebugText");
			  out.innerHTML =  msg + "<br/>" + out.innerHTML;
			}

			function gemOutClear() {
			  var out = document.getElementById("gemDebugText");
			  out.innerHTML = "";
			}
			
			gemOutPrintln(">debug window");
			</script>
		</div>
		<script language="javascript" src="<%=appCtx%>jsps/gwt.jsp"></script>
	</body>
</html>